package huawei;
/*
* @Author: wanghongfucoder
* @Date:   2017-06-27 15:44:49
* @Last Modified by:   wanghongfucoder
* @Last Modified time: 2017-06-28 15:13:49
*/

import java.util.Scanner;

public class Operatornum {
	public static void main(String[] args) {
		String str1="ab12cd3";
		String str2="abcdf";
		int[][] result=new int[str1.length()+1][str2.length()+1];
		int ic=5,dc=3,rc=2;
		for (int i=0; i<=str1.length();i++) {
			result[i][0]=dc*i;
		}

		for (int j=0; j<=str2.length(); j++) {
			result[0][j]=ic*j;
		}

		for (int i=1; i<=str1.length(); i++) {
			for (int j=1; j<=str2.length(); j++) {
				int temp=0;
				if (str1.charAt(i-1)==str2.charAt(j-1)) {
					temp=result[i-1][j-1];
				}else{
					temp=result[i-1][j-1]+rc;
				}
				temp=Math.min(result[i-1][j]+dc, temp);
				temp=Math.min(result[i][j-1]+ic, temp);
				result[i][j]=temp;
			}
		}

		System.out.println(result[str1.length()][str2.length()]);
	}


    public static void changstrsame(String[] args) {
            Scanner in=new Scanner(System.in);
            while (in.hasNext()){
                String s1=in.nextLine();
                String s2=in.nextLine();
                char[] cs1=s1.toCharArray();
                char[] cs2=s2.toCharArray();
                int[][] dp=new int[s1.length()+1][s2.length()+1];
                //初始化
                for(int row=1;row<=s1.length();row++){
                    dp[row][0]=row;
                }
                for(int col=1;col<=s2.length();col++){
                    dp[0][col]=col;
                }
                //int res =0;
                for(int row=1;row<=s1.length();row++){
                    for(int col=1;col<=s2.length();col++){
                        if(cs1[row-1]==cs2[col-1]){
                            dp[row][col]=dp[row-1][col-1];
                        }
                        else{
                            int min1=Math.min(dp[row-1][col],dp[row][col-1])+1;
                            dp[row][col]=Math.min(min1,dp[row-1][col-1]+1);
 
                        }
                    }
                }
                System.out.println("1/"+ (dp[s1.length()][s2.length()]+1) );
 
            }
        }
}